from django.conf import settings
from django.db.models.signals import post_save
from django.dispatch import receiver, Signal
from rest_framework.authtoken.models import Token
from preDepositLogs.models import PreDepositLog

from django.contrib.auth import get_user_model

User = get_user_model()


@receiver(post_save, sender=PreDepositLog)
def update(sender, instance=None, created=False, **kwargs):
    print('触发信号')
    print(created)
    print(instance)

# # 参数一接收哪种信号，参数二是接收哪个model的信号
# @receiver(post_save, sender=User)
# def create_auth_token(sender, instance=None, created=False, **kwargs):
#     # 是否新建，因为update的时候也会进行post_save
#     if created:
#         password = instance.password
#         instance.set_password(password)
#         instance.save()
#
#
# user_signal = Signal(providing_args=["v1", "v2"])
#
# @receiver(user_signal, dispatch_uid="user_signal_receiver")
# def user_signal_handler(sender, **kwargs):
#     print('my_signal received')

